package com.buba.service.impl;

import com.buba.dao.DeptMapper;
import com.buba.dao.EmployeeMapper;
import com.buba.pojo.Dept;
import com.buba.pojo.Employee;
import com.buba.service.DeptService;
import com.buba.utils.PasswordUtil;
import com.buba.utils.SystemConstant;
import com.buba.utils.UUIDUtils;
import com.buba.vo.DeptVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Service
@Transactional
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptMapper deptMapper;
    @Autowired
    private EmployeeMapper employeeMapper;

    /**
     * 查询部门列表
     * @param deptVO
     * @return
     */
    public List<Dept> findDeptListByPage(DeptVO deptVO) {
        return deptMapper.findDeptListByPage(deptVO);
    }

    public int addDept(Dept dept) {
//        todo 保存创建时间
        dept.setCreateDate(new Date());

        return deptMapper.insertSelective(dept);
    }

    /**
     * 修改部门
     * @param dept
     * @return
     */
    public int updateDept(Dept dept) {

        return deptMapper.updateByPrimaryKeySelective(dept);
    }

    /**
     * 删除部门
     * @param id
     * @return
     */
    public int deleteById(Integer id) {
        return deptMapper.deleteByPrimaryKey(id);
    }

    /**
     * todo 查询所有部门
     * @param
     * @return
     */
    public List<Dept> findDeptList() {
        return deptMapper.findDeptList();
    }




}
